<template>
  <el-slider v-model="value" v-bind="controlProps"></el-slider>
</template>

<script>

import FormBase from './mixins/FormBase'

export default {
  name: 'FormSlider',
  mixins: [FormBase],
  computed: {
    value: {
      get: function() {
        return this.controlValue.reduce((r, c) => {
          if (typeof c === 'string') {
            // 截取
            let intercept = c.replaceAll(this.controlConfigs.suffix || '', '')
            // 类型转换
            let convert = Number(intercept)
            // 转换失败校验处理
            if (window.isNaN(convert)) convert = 0
            r.push(convert)
          } else if (typeof c === 'number') {
            r.push(c)
          } else {
            r.push(0)
          }
          return r
        }, [])
      },
      set: function(v) {
        const controlValue = v.reduce((r,c)=>{
          r.push(`${c}${this.controlConfigs.suffix || ''}`)
          return r
        },[])
        this.$emit('change', controlValue)
      }
    }
  },
  mounted() {

  }
}
</script>

<style scoped lang="scss">
</style>
